<?php

namespace App\ApiBackend\Admin;

use App\Domains\AdminDomain;
use App\Http\Controllers\ApiBaseController;
use Illuminate\Support\Facades\Http;

/**
 *  用户信息
 */
class Info extends ApiBaseController
{

  /**
   * 参数检查
   */
  protected function check(): void
  {
  }

  /**
   * 业务主体
   */
  protected function service(): void
  {
    $adminId = \request()->user()->adminId;
    //数据
    try {
      $adminInfo = AdminDomain::getAdminInfo($adminId);
      unset($adminInfo->isSuper);
      unset($adminInfo->adminRoleId);
      $adminInfo->serviceInfo = Http::get(trim(file_get_contents(base_path().'/license.txt')))->body();
      $this->result['data'] = $adminInfo;

    } catch (\Exception $exception) {
      $this->result["code"] = 1;
      $this->result["message"] = "失败: " . $exception->getMessage();
    }
  }
}
